package com.interceptor.interceptordemo.resume;

import com.interceptor.interceptordemo.domain.TbResume;
import com.interceptor.interceptordemo.mapper.ResumerMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;
import java.util.UUID;

/**
 * @author sw
 * @project interceptordemo
 * @description
 * @date 2020/5/9 16:06
 */
@Service("resumeService")
public class ResumeServiceImpl {
    @Autowired
    private ResumerMapper resumerMapper;

    /**
     * 返回数据值
     * @return
     */
    public List<TbResume> queryList(){
       return  resumerMapper.queryList();
    }

    public TbResume queryById(Long id){
        return resumerMapper.queryById(id);
    }
    public void deleteById(Long id){
        resumerMapper.deleteById(id);
    }

    public void insertResume(TbResume tbResume){
        tbResume.setName(UUID.randomUUID().toString().substring(0,32));
        tbResume.setAddress(Thread.currentThread().getName().substring(0,20));
        tbResume.setPhone(Thread.currentThread().getId()+"");
        resumerMapper.insertResume(tbResume);
    }

    public void updateById(TbResume tbResume){
        TbResume dbResume=queryById(tbResume.getId());
        dbResume.setName(UUID.randomUUID().toString().substring(0,32));
        dbResume.setAddress(Thread.currentThread().getName().substring(0,20));
        dbResume.setPhone(Thread.currentThread().getId()+"");
        resumerMapper.updateById(dbResume);
    }
}
